package com.vq3.digitalizationsoftwareintegrates.Utils.DateUtils;

import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_WebSocketMessageEntity;
import com.vq3.digitalizationsoftwareintegrates.Entity.Spot_Check.MongoDBEntity.MongoDB_S_C_WebSocketSendMessageEntity;

import java.util.Calendar;
import java.util.Date;

public class GetServerDate {

    /**获取本地年
     * */
    public static int getYear() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.YEAR);
    }
    /**获取本地月
     * */
    public static int getMonth() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.MONTH)+1;
    }
    /**获取本地日
     * */
    public static int getDate() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.DATE);
    }
    /**获取本地时
     * */
    public static int getHour() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.HOUR_OF_DAY);
    }
    /**获取本地分
     * */
    public static int getMinute() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.MINUTE);
    }
    /**获取本地秒
     * */
    public static int getSecond() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(Calendar.SECOND);
    }

    /**获取明天
     * */
    public static Date tomorrow(Date today) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);
        calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) + 1);
        return calendar.getTime();
    }
    /**获取明天零点
     * */
    public static Date tomorrowInZero(Date today) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);
        calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) + 1);
        calendar.set(Calendar.HOUR_OF_DAY,0);
        calendar.set(Calendar.SECOND,0);
        calendar.set(Calendar.MINUTE,0);
        return calendar.getTime();
    }
    /**给日期加一秒
     * */
    public static Date dateAddMINUTE(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.MINUTE,1);
        return calendar.getTime();
    }
    /**设置时间戳
     * */
    public static MongoDB_S_C_WebSocketSendMessageEntity getMessageTime(MongoDB_S_C_WebSocketSendMessageEntity messageEntity) {
        messageEntity.setYear(getYear());
        messageEntity.setMonth(getMonth());
        messageEntity.setDay(getDate());
        messageEntity.setHour(getHour());
        messageEntity.setMinute(getMinute());
        messageEntity.setSecond(getSecond());
        return messageEntity;
    }
    /**设置时间戳
     * */
    public static MongoDB_S_C_WebSocketMessageEntity getMessageTime(MongoDB_S_C_WebSocketMessageEntity messageEntity) {
        messageEntity.setYear(getYear());
        messageEntity.setMonth(getMonth());
        messageEntity.setDay(getDate());
        messageEntity.setHour(getHour());
        messageEntity.setMinute(getMinute());
        messageEntity.setSecond(getSecond());
        return messageEntity;
    }

}
